package main

import (
	"db_demo/dal/sql"
	"db_demo/dal/sqlx"
	"db_demo/model"
	"fmt"
)

func main() {
	// database / sql
	fmt.Printf("%+v", sql.QueryUserById(1))
	for i, user := range sql.QueryUserByName("wxy") {
		fmt.Printf("user_%v: %+v\n", i, user)
	}
	sql.InsertUser("xdd", 25)
	sql.UpdateRowDemo()
	sql.DeleteUser(5)
	sql.PrepareQueryDemo()
	sql.PrepareInsertDemo()
	sql.TransactionDemo()

	fmt.Printf("%+v", sqlx.QueryUserById(7))
	for i, user := range sqlx.QueryUserByName("xdd") {
		fmt.Printf("user_%v: %+v\n", i, user)
	}
	sqlx.InsertUser("大话", 18)
	sqlx.UpdateUser()
	sqlx.DeleteUserById(19)
	sqlx.NamedInsertUser("够酷那个", 30)
	sqlx.NamedQueryUserByName("wxy")
	sqlx.BatchInsertUsers2([]interface{}{
		model.User{
			Name: "test1",
			Age:  53,
		},
		model.User{
			Name: "test2",
			Age:  100,
		},
		// model.User{
		// 	Name: "test3",
		// 	Age:  53,
		// },
		// model.User{
		// 	Name: "test4",
		// 	Age:  100,
		// },
	})
	sqlx.BatchInsertUsers3([]*model.User{
		{
			Name: "qimi",
			Age:  53,
		},
		{
			Name: "xxxx",
			Age:  100,
		},
	})
}
